package main

import (
	"fmt"
	"time"
)

var channel = make(chan int)

// 写端: channel <- "hehe"  写端写数据,读端不再读  ==>阻塞
// 读端: str := <- channel  读端读数据,同时写端不再写  ==>阻塞

func main() {
	ch := make(chan int)

	go func() {
		for i := 0; i < 5; i++ {
			fmt.Println("子Go程,i=", i)
			ch <- i
		}
	}()

	time.Sleep(time.Second * 2)

	for i := 0; i < 5; i++ {
		num := <-ch
		fmt.Println("主Go程读,num=", num)
	}

}
